using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;

namespace Faust.Andrew.MTG.Player.Converters
{
    public class TapStateToRotationTransformation : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            if (!(value is Shared.CardState))
            {
                return null;
            }

            Shared.CardState state = (Shared.CardState)value;
            if (state == Faust.Andrew.MTG.Player.Shared.CardState.Normal)
            {
                return null;
            }
            else
            {
                //It's tapped so we need to return a render transformation with it rotated 90 degrees
                RotateTransform rotation = new RotateTransform();
                //Rotate counterclockwise
                rotation.Angle = -90;
                rotation.CenterX = 0.5;
                rotation.CenterY = 0.5;
                return rotation;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new Exception("TapStateToRotationTransformation only supports one way binding");
        }

        #endregion
    }
}
